<template>
    <!--<h1>This is newsInformation page  id:======>{{$route.params.id}}</h1>-->
    <div class="newsInfo-container">
        <!--大标题-->
        <h3 class="title">{{newsInfo.title}}</h3>
        <!--小标题-->
        <p class="subTitle">
            <span>发表时间 {{newsInfo.time}}</span>
            <span>浏览数 {{newsInfo.count}}</span>
        </p>

        <!--内容-->
        <div class="content" v-html="newsInfo.content"></div>
        {{$route.params.id}}

        <!--评论子组件-->
        <comment-box :id="this.id"></comment-box>

    </div>
</template>

<script>

    import {Toast} from 'mint-ui'

    //导入评论子组件
    import comment from '../subcomponent/comment.vue'

    export default {
        name: "newsInfo",
        data(){
            return {
                id:this.$route.params.id,
                newsInfo:[]
            }
        },
        created(){
            this.getNewsInfo()
        },
        methods:{
            getNewsInfo(){
                this.$http.get('./src/data/newsInfo.json').then(result => {
                    if (result.body.status === "E0") {
                        this.newsInfo = result.body.data[0];
                    }else{
                        Toast(result.body.message);
                    }
                });
            }
        },
        components:{
            //注册子组件
            "comment-box":comment
        }

    }
</script>

<style lang="scss" >
    .newsInfo-container{

        padding: 0 4%;
        .title{
            font-size: 16px;
            text-align: center;
            margin: 15px 0;
            color: #ee4935;
        }
        .subTitle{
            color: #23adee;
            display: flex;
            justify-content: space-between;
        }
        .content{
            border-top: 1px solid lightgray;
            padding-top: 10px;
            img{
                width: 100%;
                height: 100%;
            }
        }
    }

</style>